package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.declare.cebPay.request.CebPayQueryRequest;
import com.dwms.entity.declare.cebPay.request.CebPayRequest;
import com.dwms.entity.declare.cebPay.response.CebPayResponse;
import com.dwms.feign.declare.CebPayFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: CebPayController
 * @Description: CebPay
 * @Create 2025-09-15 23:06:58
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "支付备案信息")
@RestController
@RequestMapping(value = "/declare/cebPay")
@RequiredArgsConstructor
public class CebPayController {

    private final HttpServletRequest request;
    private final CebPayFeignClient cebPayFeignClient;

    /**
     * 修改
     *
     * @param cebPayRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result update(@RequestBody CebPayRequest cebPayRequest) {
        WebUtil.getAdminRequest(request, cebPayRequest);
        return cebPayFeignClient.update(cebPayRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebPayResponse>> findPage(@RequestBody CebPayQueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return cebPayFeignClient.findPage(query);
    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request, query);
        return this.cebPayFeignClient.findById(query);
    }

}
